package com.localjoycommunity.cpdj.project.system.mapper;

import com.localjoycommunity.cpdj.project.system.domain.SysQuestion;
import com.localjoycommunity.cpdj.project.system.domain.vo.OptionVo;
import com.localjoycommunity.cpdj.project.system.domain.vo.QuestionVo;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 试题Mapper接口
 *
 * @author leepandar
 * @date 2020-11-01
 */
public interface SysQuestionMapper {
    /**
     * 查询试题
     *
     * @param questionId 试题ID
     * @return 试题
     */
    public SysQuestion selectSysQuestionById(Long questionId);

    /**
     * 查询试题列表
     *
     * @param sysQuestion 试题
     * @return 试题集合
     */
    public List<SysQuestion> selectSysQuestionList(SysQuestion sysQuestion);


      @Select(
          "select pq.paper_id,q.question_id,q.title,q.`type`,q.correct_option,q.analysis,q.score\n"
              + " from sys_paper_question as pq left join sys_question as q  on pq.question_id=q.question_id where pq.paper_id=#{paperId}")
      public List<QuestionVo> selectQuestions(long paperId);


      @Select("SELECT option_id,question_id,`option`,content FROM `two-new-party`.sys_option where question_id = #{questionId}")
      public List<OptionVo> selectOptions(long questionId);

    /**
     * 新增试题
     *
     * @param sysQuestion 试题
     * @return 结果
     */
    public int insertSysQuestion(SysQuestion sysQuestion);

    /**
     * 修改试题
     *
     * @param sysQuestion 试题
     * @return 结果
     */
    public int updateSysQuestion(SysQuestion sysQuestion);

    /**
     * 删除试题
     *
     * @param questionId 试题ID
     * @return 结果
     */
    public int deleteSysQuestionById(Long questionId);

    /**
     * 批量删除试题
     *
     * @param questionIds 需要删除的数据ID
     * @return 结果
     */
    public int deleteSysQuestionByIds(Long[] questionIds);

    List<SysQuestion> selectQuestionByPaperId(Long paperId);
}
